//
//  HBNewestController.m
//  HeartBeat
//
//  Created by karong on 2023/8/25.
//

#import "HBNewestController.h"
#import "HBNewestCell.h"
#import "HBNewestRequest.h"

@interface HBNewestController ()
@property (weak, nonatomic) IBOutlet UICollectionView *listView;
@end

@implementation HBNewestController

- (void)viewDidLoad {
    [super viewDidLoad];
    HBNewestRequest * request = [HBNewestRequest new];
    self.request = request;
}

- (BOOL)disableAutoBeginRefresh {
    return YES;
}

- (void)showNovelDetailWithNovel:(id)novel {
    [ViewManager pushNovelDetailVCWithNovel:novel inController:self];
}
#pragma mark - UICollectionViewDelete

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HBNewestCell *newestCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HBNewestCell" forIndexPath:indexPath];
    [newestCell setDataWithObject:self.dataArray[indexPath.row]];
    return newestCell;
}


#pragma mark - UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGSize size = CGSizeZero;
    size.width = HBScreenWidth;
    size.height = 92.5;
    return size;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    [self showNovelDetailWithNovel:self.dataArray[indexPath.row]];
}

@end
